1. Field of the Invention
The present invention relates to a jump code generator provided as a part of interrupt selecting function external to a central processing unit, an interrupt program selection system and an interrupt program selection method for selecting an interrupt program corresponding to an interrupt program execution request and, and a computer with these functions.
2. Description of the Related Art
During program execution, a central processing unit receives interrupt program execution requests from such units as sensors. Upon receiving an interrupt processing request, the central processing unit must identify the cause and select an interrupt program corresponding to the interrupt processing request.
In most cases, the central processing unit has a table (hereafter called a start address table) containing the start addresses of interrupt programs, each corresponding to a particular type of interrupt request, so as to immediately switch to execution of an interrupt program (first conventional system). When the central processing unit receives an interrupt request, it passes control to the corresponding interrupt program.
FIG. 1 is a diagram showing the concept of the interrupt program selection function of the central processing unit in a conventional system.
As shown in the figure, the storage area of the storage unit used by the central processing unit contains an execution start-address table 101 which contains the execution start-addresses AD (#1) to AD (#4) corresponding to interrupt processing requests #1, #2, #3, and #4, a control program storage area 102 in which the control program resides, and an interrupt program storage area 103 in which interrupt programs P (#1) to P (#4) reside.
When an interrupt processing request is received from an external unit, an execution start address (e.g., AD (#2)) is read from the execution start-address table 101 and is set in a program counter in the central processing unit. An interrupt program P (#2), specified by the execution start address AD (#2), is then read from the interrupt program storage area 103 for execution by the central processing unit.
However, in many cases, some central processing units which are designed to aim high-speed processing of normal processes, such as a reduced-instruction set computer, bypass the above-described interrupt program selection function because of its complexity. As an alternative, these central processing units execute a program (interrupt service routine) common to all types of interrupt requests. This program identifies the cause of an interrupt and passes control to a corresponding interrupt program, implementing the interrupt program selection function by means of software (second conventional system).
FIG. 2 is a diagram showing the concept of the interrupt program selection function of the second conventional system.
As shown in the figure, the storage area of the program storage unit used by this type of central processing unit includes a control program storing area 201 for storing a control program, an interrupt service routine storing area 202 for storing an interrupt service routine, an address table 203 containing data items, AD (#1) to AD (#4), for the start addresses of interrupt programs corresponding to interrupt processing requests #1, #2, #3, and #4, and an interrupt programs storing area 204 for storing interrupt programs P (#1) to P (#4) corresponding to interrupt processing requests #1 to #4.
When the central processing unit receives an interrupt processing request (T1 in FIG. 2) from an external unit, it interrupts the control program in execution stored in the control program storing area 201 and starts the interrupt service routine stored in the interrupt service routine storing area 202 (T2). This interrupt service routine checks the content of an interrupt request hold register 205 which stores the accepted interrupt number as a flag (T3). Based on the accepted interrupt number (for example, #2), the central processing unit gets the interrupt handler start address of interrupt number #2 from the address table 203, and passes control to the corresponding interrupt program (T4).
The following explains more in detail the interrupt service routine, the key routine of the software-controlled interrupt program selection function, by referring to FIG. 3.
FIG. 3 shows an example of an interrupt service routine used in the above-described second conventional system. It contains coding in the interrupt service routine for selecting an interrupt processing program and for passing control to the selected interrupt processing program.
In the figure, r1 to r4 are general-purpose registers (32 bits each ) and IntNumber indicates a memory address at which an interrupt number is stored. TableAddress indicates the start address of the address table 203.
During processing t1 in the interrupt service routine, an interrupt number is obtained. First, in step 1 in processing t1, the content of the high-order 16 bits of IntNumber is stored in the high-order 16 bits of general-purpose register r1. In step 2, the value of the area pointed to by the content of general-purpose register r1 is stored in general-purpose register r1. Because general-purpose register r1 contains the memory address at which the interrupt number is stored, the interrupt number is stored in general-purpose register r1. That is, in steps 1 and 2, the content of the area pointed to by IntNumber, i.e., the interrupt number, is stored in general-purpose register r1. In step 3, the content of general-purpose register r1, which is the interrupt number, is multiplied by the number of bytes of an element of the address table 203 so that the corresponding address is indexed. In this case, an element of the address table 203 is composed of four bytes.
In processing t2, the address of an interrupt program is calculated. In step 1 in processing t2, the content of the high-order 16 bits of TableAddress is stored in the high-order 16 bits of general-purpose register r2. In step 2, the content of the low-order 16 bits of TableAddress is added to the low-order 16 bits of general-purpose register r2. In steps 1 and 2 in processing t2, the value of TableAddress is stored in general-purpose register r2. In step 3, the address at which the start address of the interrupt program corresponding to the interrupt is stored is calculated.
In processing t3, the content stored at the address calculated in step 3 in processing t2 is read (The start address of the interrupt program is obtained).
In processing t4, control jumps to the address obtained in processing t3. (jump to the interrupt program).
However, as shown in the second conventional system described above, software implementation of the interrupt program selection function for selecting an interrupt program upon receiving an interrupt request is complicated, thus degrading a response to an interrupt request.